package com.example.seckill.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: seckill
 * @description: rabbitmq发送消息演示类
 * @author: KingCrimson
 * @create: 2022-08-18 09:55
 **/

@Service
@Slf4j
public class MQSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

//    public void send(Object msg){
//        log.info("发送消息:"+msg);
//        rabbitTemplate.convertAndSend("queue",msg);
//    }

    /**
    * @Description: 发送秒杀信息
    * @Param: 
    * @return: 
    * @Author: KingCrimson
    * @Date: 2022/8/18
    */
    public void sendSeckillMessage(String message){
        log.info("发送的信息:"+message);
        rabbitTemplate.convertAndSend("seckillExchange","seckill.message",message);
    }

}
